package com.fametal.ui.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

import com.fametal.GlobalConstant.Settings;
import com.fametal.R;
import com.fametal.ui.utils.Utils;

public class DVDControlActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		setContentView(R.layout.dvd_control);
		
	}
	
	private boolean poweroff = true;
	public void onClick(View view) {
		String operation = null;
		switch (view.getId()) {
		case R.id.dvd_power:
			Button bt = (Button)view;
			if(poweroff == true){
				bt.setText(getResources().getString(R.string.poweroff));
				operation = "poweron";
				poweroff = false;
			}else{
				bt.setText(getResources().getString(R.string.power));
				operation = "poweroff";
				poweroff = true;
			}
			break;
		case R.id.dvd_play:
			operation = "play";
			break;
		case R.id.dvd_pause:
			operation = "pause";
			break;
		case R.id.dvd_stop:
			operation = "stop";
			break;
		case R.id.dvd_speed:
			operation = "fastforward";
			break;
		case R.id.dvd_fast_backword:
			operation = "fastbackward";
			break;
		case R.id.dvd_previous:
			operation = "prev";
			break;
		case R.id.dvd_next:
			operation = "next";
			break;
		case R.id.dvd_track:
			operation = "audio_track";
			break;
		case R.id.dvd_caption:
			operation = "subtitle";
			break;
		case R.id.dvd_take_out_storage:
			operation = "eject";
			break;
		case R.id.dvd_menu:
			operation = "menu";
			break;
			
		case R.id.dvd_one:
			operation = "1";
			break;
		case R.id.dvd_two:
			operation = "2";
			break;
		case R.id.dvd_three:
			operation = "3";
			break;
		case R.id.dvd_four:
			operation = "4";
			break;
		case R.id.dvd_five:
			operation = "5";
			break;
		case R.id.dvd_six:
			operation = "6";
			break;
		case R.id.dvd_seven:
			operation = "7";
			break;
		case R.id.dvd_eight:
			operation = "8";
			break;
		case R.id.dvd_nine:
			operation = "9";
			break;
		case R.id.dvd_ten:
			operation = "+10";
			break;
		case R.id.dvd_zero:
			operation = "0";
			break;	
			
		case R.id.dvd_up:
			operation = "up";
//			operation = "上";
			break;
		case R.id.dvd_left:
			operation = "left";
//			operation = "左";
			break;
		case R.id.dvd_ok:
			operation = "confirm";
//			operation = "确定";
			break;
		case R.id.dvd_right:
			operation = "right";
//			operation = "右";
			break;
		case R.id.dvd_down:
			operation = "down";
//			operation = "下";
			break;
		}
		if(operation != null && !operation.equals("")){
			String url = Settings.IP + "cgi-bin/DVD_control.cgi?operation=" + operation;
			get(url);
		}
	}
	
	public void get(String url) {
		Utils.get(getParent(), url, false);
	}

}
